//
//  DateSelect.m
//  Traveling
//
//  Created by 尹桥印 on 15/6/13.
//  Copyright (c) 2015年 长沙市岳麓区立早网络科技有限公司. All rights reserved.
//

#import "DateSelect.h"


@interface DateSelect()

@property (nonatomic, copy) void (^cancelBtnClick)();
@property (nonatomic, copy) void (^enterBtnClick)(NSDate *date);

@property (weak, nonatomic) IBOutlet UIDatePicker *datePicker;
@end
@implementation DateSelect


+(instancetype)dateSelectWithCancelBtnClick:(void (^)())cancel enterBtnClick:(void (^)(NSDate *date))enterBtnClick currentDate:(NSDate *)currentDate minDate:(NSDate *)minDate{
    DateSelect *select = [[[NSBundle mainBundle] loadNibNamed:@"DateSelect" owner:nil options:nil] lastObject];
    select.cancelBtnClick = cancel;
    [select.datePicker setDate:currentDate];
    [select.datePicker setMinimumDate:minDate];
    select.enterBtnClick = enterBtnClick;
    return select;
}

- (IBAction)cancelBtnClick:(id)sender {
    if (self.cancelBtnClick) {
        self.cancelBtnClick();
    }
}

- (IBAction)enterBtnClick:(id)sender {
    if (self.enterBtnClick) {
        self.enterBtnClick(self.datePicker.date);
    }
}

@end
